import Entity from "../math/Entity";
import { ctx } from "../WebGLRenderer";

export class Scene {
  constructor(){
    this.children = [];
  }

  add(object){
    if(!(object instanceof Entity)) return;
    this.children.push(object);
    this.render();
  }

  render(){
    ctx.gl.clear(ctx.gl.COLOR_BUFFER_BIT);
    this.children.forEach(item=>item.render(ctx.gl))
    // this.children.forEach(item=>{
    //   assignVertexAttrib3f(ctx.gl, glLocation.a_Position, item.x, item.y, item.z);
    //   assignVertexAttrib1f(ctx.gl, glLocation.a_PointSize, 20.0);
    //   // Clear <canvas>
    //   ctx.gl.drawArrays(ctx.gl.POINTS, 0, 1);
    // })
  }
}